2 require_once 'modules/Campaigns/Campaign.php';
3 require_once 'modules/CampaignTrackers/CampaignTracker.php';
5 class CampaignTrackersTest extends Sugar_PHPUnit_Framework_TestCase
7 var $campaign = 'campaignforcamplogunittest';
11 public function setup()
14 $current_user = SugarTestUserUtilities::createAnonymousUser();
15 //for the purpose of this test, we need to create a campaign and relate it to a campaign tracker object
19 $c->name = 'CT test ' . time();
20 $c->campaign_type = 'Email';
21 $c->status = 'Active';
22 $timeDate = new TimeDate();
23 $c->end_date = $timeDate->to_display_date(date('Y')+1 .'-01-01');
24 $c->assigned_id = $current_user->id;
26 $c->team_set_id = '1';
30 //create campaign tracker
31 $ct = new CampaignTracker();
32 $ct->tracker_name ='Campaign Tracker Test ' . time();
33 $ct->tracker_url = 'sugarcrm.com';
34 $ct->campaign_id = $this->campaign->id;
36 $this->campaign_tracker = $ct;
43 public function tearDown()
45 //delete the campaign and campaign tracker
46 $GLOBALS['db']->query('DELETE FROM campaign_log WHERE campaign_id = \''.$this->campaign->id.'\' ');
47 $GLOBALS['db']->query('DELETE FROM campaign_tracker WHERE id = \''.$this->campaign_tracker->id.'\' ');
48 unset($this->campaign_tracker);
49 unset($this->campaign_log );
50 unset($GLOBALS['current_user']);
54 public function testSave(){
55 //save was already performed, so just confirm that the http protocol got added on save
56 $this->assertSame('http://sugarcrm.com', $this->campaign_tracker->tracker_url, 'http protocol was not added to campaign_tracker->tracker_url on save');
62 public function testFillInAdditionalDetailFields(){
65 $this->campaign_tracker->fill_in_additional_detail_fields();
67 //test that campaign name gets filled in
68 $this->assertSame($this->campaign->name, $this->campaign_tracker->campaign_name, 'campaign name was not set properly during function call');
70 //test that message url gets filed out
71 $this->assertFalse(empty($this->campaign_tracker->message_url), 'message url was not populated correctly during function call');
74 public function testGetSummaryText(){
75 //test that tracker name is returned
76 $this->assertSame($this->campaign_tracker->tracker_name, $this->campaign_tracker->get_summary_text(), 'campaign tracker name is not set properly in summary text');